home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_lib.arc / FLRETATR.C < prev    next >
Text File  |  1990-08-09  |  2KB  |  61 lines

  1. /**
  2. *
  3. *  Name         flretatr -- Return file attribute
  4. *
  5. *  Synopsis     ercode = flretatr(pfile,pattrib);
  6. *               int  ercode       Returned DOS function error code
  7. *               char *pfile       File path name
  8. *               int  pattrib      Returned file attribute
  9. *
  10. *  Description  This function returns the file attribute of the specified
  11. *               file.  See FLCREATE for the possible attributes.
  12. *
  13. *  Returns      ercode            DOS 2.0 function return error code
  14. *               pattrib           File attribute.  If an error is encountered
  15. *                                 -1 is returned.
  16. *
  17. *  Version      1.0  (C)Copyright Blaise Computing Inc.  1983
  18. *
  19. **/
  20. #include <compiler.h>
  21.  
  22. struct dreg
  23. {
  24.   unsigned ax,bx,cx,dx,si,di,ds,es;
  25. };
  26. #define DOSREG  struct dreg
  27.  
  28. int flretatr(pfile,pattrib)
  29. char *pfile;
  30. int  *pattrib;
  31. {
  32.  
  33.     DOSREG dos_reg;
  34.     int    ercode,utinit(),dos();
  35. #if CI201A & LDATA
  36.     unsigned long ptrtoabs();
  37. #endif
  38.  
  39.     utinit(&dos_reg);                  /* Initialize registers         */
  40.     dos_reg.ax = 0x4300;               /* Function 43, return attribute*/
  41. #if LDATA
  42. #if CI201A
  43.     dos_reg.ds = (unsigned)((ptrtoabs(pfile) & 0xffff0L) >> 4L);
  44.     dos_reg.dx = (unsigned)(ptrtoabs(pfile) & 0xfL);
  45. #else
  46.     dos_reg.ds = (unsigned)(((long)(pfile) & 0xffff0L) >> 4L);
  47.     dos_reg.dx = (unsigned)((long)(pfile) & 0xfL);
  48. #endif
  49. #else
  50.     dos_reg.dx = (unsigned)pfile;
  51. #endif
  52.     ercode     = dos(&dos_reg);
  53.     if (ercode == 0)
  54.        *pattrib = (int)dos_reg.cx;
  55.     else
  56.        *pattrib = -1;
  57.  
  58.     return(ercode);
  59.  
  60. }
  61.